<%@page import="com.xnx3.j2ee.Global"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
<%@ taglib uri="http://www.xnx3.com/java_xnx3/xnx3_tld" prefix="x" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<jsp:include page="../../../../iw/common/head.jsp">
	<jsp:param name="title" value="用户列表"/>
</jsp:include>
<script src="<%=basePath+Global.CACHE_FILE %>Branch_branchid.js"></script>
<script src="<%=basePath+Global.CACHE_FILE %>Role_role.js"></script>

<jsp:include page="../../../../iw/common/list/formSearch_formStart.jsp" ></jsp:include>
	<jsp:include page="../../../../iw/common/list/formSearch_input.jsp">
		<jsp:param name="iw_label" value="用户名"/>
		<jsp:param name="iw_name" value="username"/>
	</jsp:include>
	
    <input class="layui-btn iw_list_search_submit" type="submit" value="搜索" />
    
    <div style="float: right; " class="layui-form">
		<script type="text/javascript"> orderBy('id_DESC=编号,lasttime_DESC=最后登陆时间'); </script>
	</div>
</form>

<script>
//输入branchid，输出部门名字
function writeBranchName(branch_id){
	var branchName = branchid[branch_id];
	if(typeof(branchName) == 'undefined' || branchName == 'undefined'){
		branchName = '尚未设定';
	}
	document.write(branchName);
}
</script>

<table class="layui-table iw_table">
  <thead>
    <tr>
		<th>ID</th>
        <th>用户名</th>
        <th>昵称</th>
        <th>最后上线时间</th>
        <th>权限</th>
        <th>所属部门</th>
        <th>操作</th>
    </tr> 
  </thead>
  <tbody>
  	<c:forEach items="${list}" var="user">
  		<tr>
          <td style="width:28px; cursor: pointer;" onclick="userView(${user.id });">${user.id }</td>
          <td style="width:58px; cursor: pointer;" onclick="userView(${user.id });">${user.username }</td>
          <td style="cursor: pointer;" onclick="userView(${user.id });"><x:substring maxLength="15" text="${user.nickname }"></x:substring> </td>
          <td style="width:100px;"><x:time linuxTime="${user.lasttime }" format="yy-MM-dd hh:mm"></x:time></td>
          <td><script type="text/javascript">writeName('${user.authority }');</script></td>
          <td><script type="text/javascript">writeBranchName('${user.branchid}');</script></td>
          <td style="width: 60px;">
          		<botton class="layui-btn layui-btn-sm" onclick="updateBranch('${user.id}','${user.nickname }');" style="margin-left: 3px;">修改部门</botton>
          </td>
      </tr>
    </c:forEach>
  </tbody>
</table>
<!-- 通用分页跳转 -->
<jsp:include page="../../../../iw/common/page.jsp"></jsp:include>


<script type="text/javascript">

//查看用户详情信息
function userView(id){
	layer.open({
		type: 2, 
		title:'查看用户信息', 
		area: ['460px', '630px'],
		shadeClose: true, //开启遮罩关闭
		content: '<%=basePath %>admin/user/view.do?id='+id
	});
}

//修改用户所属部门
function updateBranch(userid, nickname){
	layer.open({
		type: 2, 
		title:'查看用户信息', 
		area: ['460px', '630px'],
		shadeClose: true, //开启遮罩关闭
		content: 'setBranch.do?userid='+userid
	});
}
</script>

<jsp:include page="../../../../iw/common/foot.jsp"></jsp:include>